//增大球子弹
module py2Obj {


	export class magnifyBullet extends basicObj {
		//保存外部的物理世界
		private time: egret.Timer;
		private bulletType: any;
		public isRun = false;
		public pointList: egret.Point[] = [];
		public constructor(world: any, gamePanle: any, romveSkins: any) {
			super(world, gamePanle, romveSkins);
			this.objkind = 103;

		}
		public init() {
			super.init();
		}

		public send(x, y, forcex, forcey) {
			this.m_body.type = 1;
			this.isRun = true;
			this.m_body.velocity = [0, 0];
			this.m_body.damping = 0;
			this.setPostion(x, y);
			this.setForce(forcex, forcey);
		}
		public createMyRigidbody(): p2.Body {
			var world: P2World = this.m_world;
			var skin: MImage = this.createSkin("circle4_png");
			var body: p2.Body = world.createCircleBodyShape(45);
			body.userData.skin = skin;
			body.userData.data = this;
			body.mass = 0;//质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
			//body.gravityScale=0;
			var shape = body.shapes[0];
			shape.collisionGroup = 2;//010与001为0，010与110为1
			// shape.collisionMask=2;
			// trace(shape.collisionGroup,shape.collisionMask)
			return body;
		}
		private createFixedBullet() {

		}

		public runEnd() {

			var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
			bullet.init();
			bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
			this.m_gamePanle.doMaterial(bullet.getBody());
			// bullet.setForce(this.vec.x, this.vec.y);
			// this.setChildIndex(this.gun, this.numChildren - 1);
			this.isRun = false;
			this.recyle1();
			return bullet;
		}
		public runEnd1() {
			this.m_body.type = 3;
			this.isRun = true;
		}
		public recyle1() {
			this.m_body.velocity = [0, 0];
			this.m_body.type = 2;
			this.setPostion(-100, -100);
			this.isRun = false;
		}
		public recyle() {
			this.isRun = true;
			this.m_body.type = 2;
			this.time = new egret.Timer(50, 1);
			this.time.start();//开始计时
			this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
		}
		public jishi() {
			this.isRun = true;
			this.m_body.type = 1;
		}
		public strikeRecyle(){
			this.m_body.type = 3;
		}
		/**
		 * Body.KINEMATIC = 4;
		 * Body.STATIC = 2;
		 * Body.DYNAMIC = 1;
		 */
		public getCollision(otherBody: basicObj) {
			if (otherBody.objkind == 100) {
				return;
			}
			if (otherBody.objkind == 108) {
				this.strikeRecyle();
				var bb = 1;
			}
			if (bb == null) {
				this.recyle();
			}
		}
	}
}